﻿window.onload = setRasporkaHeight;

function setRasporkaHeight() {
    var wh = getWindowHeight(); // Window Height
    var d = document.getElementById('rasporka');  // Get div element
    var dh = d.offsetHeight; // div height
    if (dh < wh)
        d.style.height = wh + 'px'; // Set div height to window height

    var pnlMain = document.getElementById('pnlMain');
    var m = parseInt(getStyle(pnlMain, "width"));
//    alert(m);

    var pnl1 = document.getElementById('panel1');
    pnl1.style.width = m + 'px';
    
    var pnl2 = document.getElementById('panel2');
    if (pnl2) {
        //ChangeVisibility(pnl2);
        pnl2.style.width = m * 0.75 + 'px';
    }

    var pnl21 = document.getElementById('panel2_1');
    if (pnl21) {
        //ChangeVisibility(pnl21);
        pnl21.style.width = m * 0.25 + 'px';
    }
};

function getStyle(el, style) {
  if(!document.getElementById) return 1;
 
   var value = el.style[toCamelCase(style)];
 
  if(!value)
    if(document.defaultView)
      value = document.defaultView.
         getComputedStyle(el, "").getPropertyValue(style);
   
    else if(el.currentStyle)
      value = el.currentStyle[toCamelCase(style)];
  
   return value;
}
function toCamelCase( sInput ) {
  var oStringList = sInput.split('-');
  if(oStringList.length == 1)  
    return oStringList[0];
  var ret = sInput.indexOf("-") == 0 ?
      oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
  for(var i = 1, len = oStringList.length; i < len; i++){
    var s = oStringList[i];
      ret += s.charAt(0).toUpperCase() + s.substring(1);
  }
  return ret;
}

function toggleVisibility(controlId) {
    var control = document.getElementById(controlId);
    if (control.style.visibility == "visible" || control.style.visibility == "")
        control.style.visibility = "hidden";
    else
        control.style.visibility = "visible";

}

function replaceButtonText(buttonId, text) {
    if (document.getElementById) {
        var button = document.getElementById(buttonId);
        if (button) {
            if (button.childNodes[0]) {
                button.childNodes[0].nodeValue = text;
            }
            else if (button.value) {
                button.value = text;
            }
            else //if (button.innerHTML)
            {
                button.innerHTML = text;
            }
        }
    }
}

function NextButtonClick() {

    ChangeVisibility(document.getElementById('panel1'));
    ChangeVisibility(document.getElementById('panel2'));
    ChangeVisibility(document.getElementById('panel2_1'));
}

function ChangeVisibility(control) {
    if (control.style.visibility == "visible" || control.style.visibility == "")
        control.style.visibility = "hidden";
    else
        control.style.visibility = "visible";
}

function getWindowHeight() {
    var windowHeight = 0;

    if (typeof (window.innerHeight) == 'number')
        windowHeight = window.innerHeight;

    else {

        if (document.documentElement && document.documentElement.clientHeight)
            windowHeight = document.documentElement.clientHeight;

        else {
            if (document.body && document.body.clientHeight)
                windowHeight = document.body.clientHeight;
        };
    };

    var e = document.getElementById('clientHeight');
    if (e != null)
        e.value = windowHeight + '';

    return windowHeight;
};